﻿// declare the user module
angular.module('app.user', ['ui.router', 'app.common'])
	.config(['$stateProvider', function ($stateProvider) {
	'use strict';
		// base user state
	var userState = {
		abstract: true,
		name: 'user',
		url: '/user/{userId}',
		templateUrl: '/app/user/views/UserContainer.html',
		controller: 'UserController'
	},
	// library view
	userLibraryView = {
		templateUrl: '/app/user/views/UserLibrary.html',
		controller: 'UserLibraryController'
	},
	// uplaod panel
	userImageUploadView = {
		templateUrl: '/app/user/views/UserImageUpload.html',
		controller: 'UserImageUploadController'
	},
	// user profile view
	userProfileView = {
		templateUrl: '/app/user/views/UserProfile.html',
		controller: 'UserProfileController'
	},
	// view user abstract state
	userViewState = {
		abstract: true,
		name: 'user.view',
		views: {
			'user-content': userLibraryView,
			'user-action': userImageUploadView,
			'user-details': userProfileView,
		}
	},
	// view library state
	userViewLibraryState = {
		name: 'user.view.library',
		url: '/view',
		views: {
			'folders-view': {
				templateUrl: '/app/user/views/UserLibraryFolders.html',
				controller: 'UserLibraryFolderController'
			},
			'images-view': {
				templateUrl: '/app/user/views/ViewImages.html',
				controller: 'UserViewImagesController'
			}
		}
	},
	// view specific folder
	userViewFolderState = {
		name: 'user.view.library.folder',
		url: '/folder/{folderId}'
	},
	// favorites view
	userViewFavoritesState = {
		name: 'user.view.library.favorites',
		url: '/favorites'
	},
	// edit a user view
	userEditView = {
		templateUrl: '/app/user/views/ChangePassword.html',
		controller: 'UserProfileEditController'
	},
	// edit user state
	userChangePasswordState = {
		name: 'user.edit',
		url: '/edit',
		views: {
			'user-content': userEditView
		}
	};

	$stateProvider
		.state(userState)
		.state(userViewState)
		.state(userViewLibraryState)
		.state(userViewFolderState)
		.state(userViewFavoritesState)
		.state(userChangePasswordState);
}]);